import Vuex from 'vuex'
import Vue from 'vue'
import * as types from './types'

Vue.use(Vuex)

const store =  new Vuex.Store({
	state:{
		user:{},
		token:false,
		title:'',
		count:0,
		hrefTo:''
	},
	mutations:{
		[types.LOGIN]:(state,data,hrefTo) =>{
			state.count++;
			localStorage.token = data;
			state.token = data;
			state.hrefTo = '';
			console.log('state.token: '+state.token)
		},
		[types.LOGOUT]:(state) =>{
			console.log(state.token)
			localStorage.removeItem('token');
			state.token = false;
		},
		[types.TITLE]:(state,data) => {
			state.title = data;
		}
	}
});
export default store;
